#ifndef __WORLDMODELNODE_H__
#define __WORLDMODELNODE_H__

#include "LogParser/Predicate.h"
#include "LogParser/PIterator.h"
#include "../Render/RenderNode.h"
#include <map>

typedef std::string			NodeName;
enum WMTypeID
{
	WM_OneAttr,		// The attr of the predicate is one double number;
	WM_ND,
	WM_NotDefined,
};

class WorldModelNode
{
public:
	WorldModelNode();
	~WorldModelNode();

public:
	bool mNeedLoadOmittedInfo;

	void Update( Predicate* root_p );
	RenderNode* GetRenderNode();
	void LoadOmittedInfo( RenderNode* renderNode );
	void LoadOmittedInfo( RenderNode* trgRenderNode, RenderNode* srcRenderNode );
	void CopyOmittedInfo( RenderNode* trgRenderNode, RenderNode* srcRenderNode );
	void Render();
	std::string& Context();

private:
	std::map<NodeName,WMTypeID>		m_nodes;
	std::map<NodeName,float>		m_nodes_oneFloatAttr;
	std::map<NodeName,std::string>	m_nodes_oneStringAttr;
	RenderNode*						m_RenderNode;
	std::string						m_context;

	void InitialWorldModel();
	void ClearWorldModel();
	
	void HandleNode( Predicate* p, RenderNode* renderNode );
	WMTypeID NodeType( NodeName name );
	void HandleNodeOneAttr( Predicate* p );
	void HandleNodeND( Predicate* p, RenderNode* renderNode  );

	float GetValueOneAttr( NodeName name );

	void Show();

public:
	void SetTime( float time );
	void SetNameTeamLeft( const std::string& name );
	void SetNameTeamRight( const std::string& name );
	void SetScoreLeft( float score );
	void SetScoreRight( float score );

	float Time();
	std::string NameTeamLeft();
	std::string NameTeamRight();
	float ScoreTeamLeft();
	float ScoreTeamRight();
};

#endif //__WORLDMODELNODE_H__